package com.ocom.webapi.controller;

import com.ocom.common.constant.WebApiServiceUrl;
import com.ocom.common.entity.card.EntityXfMealInfo;
import com.ocom.common.request.xfrecde.GetConsDeptByMealTimesReq;
import com.ocom.common.request.xfrecde.GetConsPerByMealTimesReq;
import com.ocom.common.resp.Result;
import com.ocom.security.utils.SecurityUtils;
import com.ocom.webapi.feign.PayConfigClientService;
import com.ocom.webapi.feign.XfRecordFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class TianGanController {

    @Autowired
    private PayConfigClientService payConfigClientService;

    @Autowired
    private XfRecordFeign xfRecordFeign;

    @PostMapping(WebApiServiceUrl.URL_perByMealTimes)
    public Result perByMealTimes(@RequestBody GetConsPerByMealTimesReq request){
        Result<List<EntityXfMealInfo>> listResult = payConfigClientService.getCompanyMealNo(request.getComId());
        request.setMealInfos(listResult.getData());
        request.setComId(SecurityUtils.getYoCiUser().getComId());
        return xfRecordFeign.getConsPerByMealTimes(request);
    }


    @PostMapping(WebApiServiceUrl.URL_deptByMealTimes)
    public Result deptByMealTimes(@RequestBody GetConsDeptByMealTimesReq request){
        request.setComId(SecurityUtils.getYoCiUser().getComId());
        return xfRecordFeign.getConsDeptByMealTimes(request);
    }

}
